<?php
/**
 * API 控制器基类
 * User: 苏近之
 * Date: 2019-03-23
 * Time: 19:51
 */

namespace app\common\base;

use app\common\enum\HttpResponseStatusCode;
use think\Controller;

class ApiController extends Controller
{
    const DEFAULT_MESSAGE = 'success';
    const DEFAULT_CODE = 0;

    public function responseWithJson($data = [], $message = self::DEFAULT_MESSAGE
        , $code = self::DEFAULT_CODE, $status = HttpResponseStatusCode::OK)
    {

        return json(compact('code', 'message', 'data'), $status);
    }
}